home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / EDWIN / ALLCOMS2.S < prev    next >
Encoding:
Text File  |  1993-06-15  |  14.8 KB  |  451 lines

  1. ;;;
  2. ;;;    Copyright (c) 1985 Massachusetts Institute of Technology
  3. ;;;
  4. ;;;    This material was developed by the Scheme project at the
  5. ;;;    Massachusetts Institute of Technology, Department of
  6. ;;;    Electrical Engineering and Computer Science.  Permission to
  7. ;;;    copy this software, to redistribute it, and to use it for any
  8. ;;;    purpose is granted, subject to the following restrictions and
  9. ;;;    understandings.
  10. ;;;
  11. ;;;    1. Any copy made of this software must include this copyright
  12. ;;;    notice in full.
  13. ;;;
  14. ;;;    2. Users of this software agree to make their best efforts (a)
  15. ;;;    to return to the MIT Scheme project any improvements or
  16. ;;;    extensions that they make, so that these may be included in
  17. ;;;    future releases; and (b) to inform MIT of noteworthy uses of
  18. ;;;    this software.
  19. ;;;
  20. ;;;    3.  All materials developed as a consequence of the use of
  21. ;;;    this software shall duly acknowledge such use, in accordance
  22. ;;;    with the usual standards of acknowledging credit in academic
  23. ;;;    research.
  24. ;;;
  25. ;;;    4. MIT has made no warrantee or representation that the
  26. ;;;    operation of this software will be error-free, and MIT is
  27. ;;;    under no obligation to provide any services, by way of
  28. ;;;    maintenance, update, or otherwise.
  29. ;;;
  30. ;;;    5.  In conjunction with products arising from the use of this
  31. ;;;    material, there shall be no use of the name of the
  32. ;;;    Massachusetts Institute of Technology nor of any adaptation
  33. ;;;    thereof in any advertising, promotional, or sales literature
  34. ;;;    without prior written consent from MIT in each case.
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;;     Modified by Texas Instruments Inc 8/15/85
  39. ;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42.  
  43. ;;;; Window Motion Commands
  44.  
  45. (define next-screen-context-lines 2)
  46.  
  47. (define-initial-command-key ("^R Next Screen" argument)
  48.   "Move down to display next screenful of text."
  49. (
  50. (define-initial-key  (integer->char 22) procedure)    ;;; C-V
  51. )
  52.   (scroll-window (current-window)
  53.          (cond ((not argument)
  54.             (- (window-y-size (current-window))
  55.                next-screen-context-lines))
  56.                ((command-argument-negative-only?)
  57.             (- next-screen-context-lines
  58.                (window-y-size (current-window))))
  59.                (else argument))))
  60.  
  61. (define-initial-command-key ("^R Previous Screen" argument)
  62.   "Move up to display previous screenful of text."
  63. (
  64. (define-initial-key  (list meta-char #\V) procedure)      ;;; M-V
  65. (define-initial-key (list alt-char (integer->char 47)) procedure)  ;;;alt-v
  66. )
  67.   (scroll-window (current-window)
  68.          (cond ((not argument)
  69.             (- next-screen-context-lines
  70.                (window-y-size (current-window))))
  71.                ((command-argument-negative-only?)
  72.             (- (window-y-size (current-window))
  73.                next-screen-context-lines))
  74.                (else (- 0 argument)))))
  75.  
  76. (define (scroll-window window n)
  77.   (if (if (negative? n)
  78.           (window-mark-visible? window
  79.          (buffer-start (window-buffer window)))
  80.           (window-mark-visible? window
  81.          (buffer-end (window-buffer window))))
  82.       (if (negative? n)
  83.     (editor-error "Beginning of buffer")
  84.     (editor-error "End of buffer")))
  85.   (window-scroll-y-relative! window n))
  86.  
  87.  
  88. ;;;; Kill Commands
  89. ;;;; Deletion
  90.  
  91. (define %delete-check
  92.   (lambda (mark1 mark2)
  93.     (if (not mark2) (editor-error "Delete exceeds buffer bounds"))
  94.     (eq? (mark-line mark1) (mark-line mark2))))
  95.  
  96. (define-initial-command-key ("^R Backward Delete Character" argument)
  97.   "Delete character before point."
  98. (
  99. (define-initial-key  #\Backspace procedure)
  100. )
  101.   (if (not argument)
  102.       (let ((m1 (mark-1+ (current-point) #F)))
  103.         (if (%delete-check (current-point) m1)
  104.             (%region-delete-char! m1)
  105.             (delete-region m1)))
  106.       (kill-region (mark- (current-point) argument #F))))
  107.  
  108. (define-initial-command-key ("^R Delete Character" argument)
  109.   "Delete character after point."
  110. (
  111. (define-initial-key  (integer->char 4) procedure)     ;;C-D
  112. )
  113.   (if (not argument)
  114.       (let ((m1 (mark1+ (current-point) #F)))
  115.         (if (%delete-check (current-point) m1)
  116.             (%region-delete-char! (current-point))
  117.             (delete-region m1)))
  118.       (kill-region (mark+ (current-point) argument #F))))
  119.  
  120. (define-initial-command-key ("^R Kill Line" argument)
  121.   "Kill to end of line, or kill an end of line."
  122. (
  123. (define-initial-key  (integer->char 11) procedure)     ;;; C-K
  124. )
  125.   (let ((point (current-point)))
  126.     (kill-region
  127.       (cond ((not argument)
  128.          (let ((end (line-end point 0 #F)))
  129.            (if (region-blank? (make-region point end))
  130.            (mark1+ end #F)
  131.            end)))
  132.         ((positive? argument)
  133.          (conjunction (not (group-end? point))
  134.               (line-start point argument 'LIMIT)))
  135.         ((zero? argument)
  136.          (line-start point 0 #F))
  137.         (else
  138.          (conjunction (not (group-start? point))
  139.               (line-start point
  140.                       (if (line-start? point)
  141.                       argument
  142.                                           (1+ argument))
  143.                       'LIMIT)))))))
  144.  
  145. (define-initial-command-key ("^R Append Next Kill" argument)
  146.   "Make following kill commands append to last batch."
  147. (
  148. (define-initial-key (list meta-char (integer->char 23)) procedure) ;;;M C-W
  149. )
  150.   (set-command-message! append-next-kill-tag))
  151.  
  152.  
  153. ;;;; Un/Killing
  154.  
  155. (define-initial-command-key ("^R Kill Region" argument)
  156.   "Kill from point to mark."
  157. (
  158. (define-initial-key (integer->char 23) procedure)       ;;; C-W
  159. )
  160.   (kill-region (current-mark)))
  161.  
  162. (define-initial-command-key ("^R Copy Region" argument)
  163.   "Stick region into kill-ring without killing it."
  164. (
  165. (define-initial-key (list meta-char #\W) procedure)              ;;; M-W
  166. (define-initial-key (list alt-char (integer->char 17)) procedure);;; alt-W
  167. )
  168.   (copy-region (current-mark)))
  169.  
  170. (define un-kill-tag
  171.   "Un-kill")
  172.  
  173. (define-initial-command-key ("^R Un-Kill" (argument 1))
  174.   "Re-insert the last stuff killed."
  175. (
  176. (define-initial-key (integer->char 25) procedure)           ;;; C-Y
  177. )
  178.   (let ((ring (current-kill-ring)))
  179.     (if (or (> argument (ring-size ring))
  180.         (ring-empty? ring))
  181.     (editor-error "Nothing to un-kill"))
  182.     (if (command-argument-multiplier-only?)
  183.     (un-kill-region (ring-ref ring 0))
  184.     (un-kill-region-reversed (ring-ref ring (-1+ argument)))))
  185.   (set-command-message! un-kill-tag))
  186.  
  187. (define-initial-command-key ("^R Pop Kill Ring" (argument 1))
  188.   " Pop kill ring"
  189. (
  190.  (define-initial-key (list ctrl-x-char (integer->char 11)) procedure)
  191. )
  192.  (let ((ring (current-kill-ring)))
  193.    (if (> argument (ring-size ring))
  194.        (editor-error "Not enough entries in the kill ring"))
  195.    (ring-stack-pop! ring argument)))
  196.  
  197. (define-initial-command-key ("^R Un-kill Pop" (argument 1))
  198.   "Correct after ^R Un-Kill to use an earlier kill."
  199. (
  200. (define-initial-key (list meta-char #\Y) procedure)              ;;; M-Y
  201. (define-initial-key (list alt-char (integer->char 21)) procedure);;;Alt-Y
  202. )
  203.   (%edwin-un-kill-pop argument))
  204.  
  205.  
  206. ;;;; Marks
  207.  
  208. (define-initial-command-key ("^R Set/Pop Mark" argument)
  209.   "Sets or pops the mark."
  210. (
  211. (define-initial-key (list alt-char (integer->char 3)) procedure)  ;;C-@
  212. )
  213.   (let ((n (command-argument-multiplier-exponent)))
  214.     (cond ((zero? n) (push-current-mark! (current-point))
  215.                      (temporary-message "Mark Set"))
  216.       ((= n 1) (set-current-point! (pop-current-mark!)))
  217.       ((= n 2) (pop-current-mark!))
  218.       (else (editor-error)))))
  219.  
  220. ;;; These are temporarily commented out becuase the C-< and C-> ar blocked
  221. ;;; by DSR.
  222.  
  223. ;;;(define-initial-command-key ("^R Mark Beginning" argument)
  224. ;;;  "Set mark at beginning of buffer."
  225. ;;;(
  226. ;;;(define-initial-key (list ctrl-^-char #\<) procedure)      ;;; C-^ <
  227. ;;;)
  228. ;;;  (push-current-mark! (buffer-start (current-buffer))))
  229. ;;;
  230. ;;;(define-initial-command-key ("^R Mark End" argument)
  231. ;;;  "Set mark at end of buffer."
  232. ;;;(
  233. ;;;(define-initial-key (list ctrl-^-char #\>) procedure)     ;;; C-^ >
  234. ;;;)
  235. ;;;  (push-current-mark! (buffer-end (current-buffer))))
  236.  
  237. (define-initial-command-key ("^R Mark Whole Buffer" argument)
  238.   "Set point at beginning and mark at end of buffer."
  239. (
  240. (define-initial-key (list ctrl-x-char  #\H) procedure)    ;;; C-X H
  241. )
  242.   (push-current-mark! (current-point))
  243.   ((if (not argument) set-current-region! set-current-region-reversed!)
  244.    (buffer-region (current-buffer))))
  245.  
  246. (define-initial-command-key ("^R Exchange Point and Mark" argument)
  247.   "Exchange positions of point and mark."
  248. (
  249. (define-initial-key (list ctrl-x-char ctrl-x-char) procedure)  ;;; C-X C-X
  250. )
  251.   (let ((point (current-point))
  252.     (mark (current-mark)))
  253.     (if (not mark) (editor-error "No mark to exchange"))
  254.     (set-current-point! mark)
  255.     (set-current-mark! point)))
  256.  
  257.  
  258. ;;;; Transposition
  259.  
  260. (define-initial-command-key ("^R Transpose Characters" (argument 1))
  261.   "Transpose the characters before and after the cursor."
  262. (
  263. (define-initial-key (integer->char 20) procedure)  ;;; C-T
  264. )
  265.   (%edwin-transpose-characters argument))
  266.  
  267.  
  268.  
  269. ;;; These are commented out becuase are not bound to any keys. These may be
  270. ;;; used with extended commands
  271.  
  272. ;;;; Search Commands
  273. ;;;; Character Search
  274.  
  275. ;;;(define-initial-command-key ("^R Character Search" argument)
  276. ;;;  "Search for a single character."
  277. ;;;(#F)
  278. ;;;  (let ((mark
  279. ;;;     (find-next-char (current-point)
  280. ;;;             (buffer-end (current-buffer))
  281. ;;;             (prompt-for-char "Character Search"))))
  282. ;;;    (if (not mark) (editor-error))
  283. ;;;    (set-current-point! (mark1+ mark #F))))
  284. ;;;
  285. ;;;(define-initial-command-key ("^R Reverse Character Search" argument)
  286. ;;;  "Search backwards for a single character."
  287. ;;;(#F)
  288. ;;;  (let ((mark
  289. ;;;     (find-previous-char (current-point)
  290. ;;;                 (buffer-start (current-buffer))
  291. ;;;                 (prompt-for-char "Reverse Character Search"))))
  292. ;;;    (if (not mark) (editor-error))
  293. ;;;    (set-current-point! (mark-1+ mark #F))))
  294.  
  295. ;;;; String Search
  296.  
  297. ;; **** This is a per-editor variable. ****
  298.    (define previous-successful-search-string "")
  299. ;;;
  300. ;;;(define-initial-command-key ("^R String Search" argument)
  301. ;;;  "Search for a character string."
  302. ;;;(#F)
  303. ;;;  (let ((string (prompt-for-string "String Search"
  304. ;;;                   previous-successful-search-string)))
  305. ;;;    (let ((mark
  306. ;;;       (find-next-string (current-point)
  307. ;;;                 (buffer-end (current-buffer))
  308. ;;;                 string)))
  309. ;;;      (if (not mark) (editor-error))
  310. ;;;      (set-current-point! (mark+ mark (string-length string) #F)))
  311. ;;;    (set! previous-successful-search-string string)))
  312. ;;;
  313. ;;;(define-initial-command-key ("^R Reverse String Search" argument)
  314. ;;;  "Search backwards for a character string."
  315. ;;;(#F)
  316. ;;;  (let ((string (prompt-for-string "Reverse String Search"
  317. ;;;                   previous-successful-search-string)))
  318. ;;;    (let ((mark
  319. ;;;       (find-previous-string (current-point)
  320. ;;;                 (buffer-start (current-buffer))
  321. ;;;                 string)))
  322. ;;;      (if (not mark) (editor-error))
  323. ;;;      (set-current-point! mark))
  324. ;;;    (set! previous-successful-search-string string)))
  325.  
  326. ;;;; Incremental Search
  327.  
  328. (define-initial-command-key ("^R Incremental Search" argument)
  329.   "Search for character string as you type it."
  330. (
  331. (define-initial-key (integer->char 19) procedure)      ;;; C-S
  332. )
  333.   (incremental-search #T))
  334.  
  335. (define-initial-command-key ("^R Reverse Search" argument)
  336.   "Incremental Search Backwards."
  337. (
  338. (define-initial-key (integer->char 18) procedure)     ;;; C-R
  339. )
  340.   (incremental-search #F))
  341.  
  342.  
  343. ;;; Word Motion
  344.  
  345.  
  346. (define-initial-command-key ("^R Forward Word" (argument 1))
  347.   "Move one or more words forward."
  348. (
  349. (define-initial-key (list meta-char #\f) procedure)               ;;; M-F
  350. (define-initial-key (list alt-char (integer->char 33)) procedure) ;;; alt-F
  351. )
  352.   (move-thing forward-word argument))
  353.  
  354. (define-initial-command-key ("^R Backward Word" (argument 1))
  355.   "Move one or more words forward."
  356. (
  357. (define-initial-key (list alt-char (integer->char 48)) procedure) ;;; alt-B
  358. (define-initial-key (list meta-char #\b) procedure)               ;;; M-B
  359. )
  360.   (move-thing backward-word argument))
  361.  
  362. (define-initial-command-key ("^R Mark Word" (argument 1))
  363.   "Set mark one or more words from point."
  364. (
  365.  (define-initial-key (list meta-char #\@) procedure)                ;;; M-@
  366.  (define-initial-key (list alt-char (integer->char 121)) procedure) ;;;alt-@
  367. )
  368.   (mark-thing forward-word argument))
  369.  
  370. (define-initial-command-key ("^R Kill Word" (argument 1))
  371.  "Kill one or more words forward"
  372. (
  373.  (define-initial-key (list meta-char #\d) procedure)              ;;;M-D
  374.  (define-initial-key (list alt-char (integer->char 32)) procedure);;; Alt D
  375. )
  376.  (kill-thing forward-word argument))
  377.  
  378. (define-initial-command-key ("^R Backward Kill Word" (argument 1))
  379.   "Kill one or more words backwards"
  380. (
  381.  (define-initial-key (list meta-char #\backspace) procedure) 
  382. )                                                            ;;; alt is blocked
  383.   (kill-thing backward-word argument))
  384.  
  385.  
  386.  
  387. ;;; Sentences
  388.  
  389.  
  390. (define-initial-command-key ("^R Forward Sentence" (argument 1))
  391.   "Move one or more sentences forward."
  392. (
  393. (define-initial-key (list meta-char #\e) procedure)               ;;; M-E
  394. (define-initial-key (list alt-char (integer->char 18)) procedure) ;;; alt-E
  395. )
  396.   (move-thing forward-sentence argument))
  397.  
  398. (define-initial-command-key ("^R Backward Sentence" (argument 1))
  399.   "Move one or more sentences forward."
  400. (
  401. (define-initial-key (list alt-char (integer->char 30)) procedure) ;;; alt-A
  402. (define-initial-key (list meta-char #\a) procedure)               ;;; M-A
  403. )
  404.   (move-thing backward-sentence argument))
  405.  
  406.  
  407. (define-initial-command-key ("^R Kill Sentence" (argument 1))
  408.  "Kill one or more sentences forward"
  409. (
  410.  (define-initial-key (list meta-char #\k) procedure)              ;;;M-K
  411.  (define-initial-key (list alt-char (integer->char 37)) procedure);;; Alt K
  412. )
  413.  (kill-thing forward-sentence argument))
  414.  
  415. (define-initial-command-key ("^R Backward Kill Sentence" (argument 1))
  416.   "Kill one or more sentences backwards"
  417. (
  418.  (define-initial-key (list ctrl-x-char #\backspace) procedure) 
  419. )                                     
  420.   (kill-thing backward-sentence argument))
  421.  
  422.  
  423.  
  424. (define-initial-command-key ("^R Forward Paragraph" (argument 1))
  425.   "Move one or more paragraph forward."
  426. (
  427. (define-initial-key (list meta-char #\]) procedure)               ;;; M-]
  428. )
  429.   (move-thing forward-paragraph argument))
  430.  
  431. (define-initial-command-key ("^R Backward Paragraph" (argument 1))
  432.   "Move one or more sentences forward."
  433. (
  434. (define-initial-key (list meta-char #\[) procedure)               ;;; M-[
  435. )
  436.   (move-thing backward-paragraph argument))
  437.  
  438.  
  439. (define-initial-command-key ("^R Mark Paragraph" (argument 1))
  440.   "mark the beginning and end of the paragraph"
  441. (
  442.  (define-initial-key (list meta-char #\h) procedure)
  443.  (define-initial-key (list alt-char (integer->char 35)) procedure)
  444. )
  445.   (let ((end (forward-paragraph (current-point) 1 'ERROR)))
  446.     (set-current-region! (make-region (backward-paragraph end 1 'ERROR) end))))
  447.  
  448.  
  449.  
  450.  
  451.